home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-04 | 6.9 KB | 220 lines | [TEXT/MPS ] |
- #
- # File: MWLocal.vu
- #
- # Contains: Sample demo working with MacWrite II 1.1 on a variety of
- # localized systems. Script assumes you have MacWrite II application
- # active.
- #
- # Written by: David Gaxiola
- #
- # Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
- #
- # Change History (most recent first):
- #
- # 3/4/96 JC Changed some checkbox ordinalities.
- # 7/20/92 DGG Edited Resources
- # 7/16/92 DGG Created.
- #
- # To Do:
- #
-
- Libraries "UtilityTasks.vulib","StandardDialogs.vulib","DataUtils.vulib",
- "QuickTasks.vulib";
- (************************************************************************************
- * Task GetLocalVersion()
- * Get the specific country for a version of Mac O/S based on the value
- * for the system descriptor.
- ************************************************************************************)
- task GetLocalVersion()
- begin
- match [system v:?sysVersion];
-
- if (sysVersion ~= /≈E1-≈/)
- return "Spanish";
- else
- return "USA";
- end;
-
- (************************************************************************************
- * Task DoSaveAsLocal(saveTitle)
- * Handle the standard file dialog in multiple languages. The global variables
- * specify the localized versions of the names to common buttons that may
- * be encountered in the Save As… dialogs.
- ************************************************************************************)
- task DoSaveAsLocal(saveTitle := 'Untitled')
- begin
- wType := dialog; #see if dialog appeared
- global gReplaceButtonName; #buttons to check for
- global gYesButtonName;
- global gSaveButtonName;
- global gSaveAsMenuItemName;
-
- println "# Handling 'SaveAs' dialog.";
- select [menuItem t:/{gSaveAsMenuItemName}≈/]; #menu selection
- type k:{ saveTitle }; #literal key strokes
- select [button t:gSaveButtonName]; #button press
- # if the file exists, the "Do you want to replace" dialog will come up
- # These if statements recognize that dialog and deal with it
- if match[window s:wType]
- begin
- if match[button t:gReplaceButtonName e:false]
- select[button t:gReplaceButtonName];
- else if match[button t:gYesButtonName e:false]
- select[button t:gYesButtonName];
- end;
- end; # task DoSaveAs
-
- (************************************************************************************
- * Task GenerateSomeText()
- * This task will output a message to the currently active window. One may
- * note that this is a modified form of the GenerateSomeText found in the
- * AppleLink.vu script.
- ************************************************************************************)
- task GenerateSomeText()
- begin
- global gTheCatcher;
- global gTheListOfStrings;
- global gFontMenuName;
- global gFormatMenuName;
- global gSizeMenuName;
- global gCharacterMenuItemName;
-
- numberOfFonts := card collect [menuItem m:gFontMenuName];
-
- println "# Now setting character attributes.";
-
- select [menuItem t:gCharacterMenuItemName m:/{gFormatMenuName}≈/];
- DoCheckBox(26);
- DoCheckBox(35);
- select [button t:/≈OK≈/ w:1];
-
- select [menuItem t:"Helvetica" m:gFontMenuName];
- select [menuItem t:"36" m:gSizeMenuName];
-
- type k:{gTheCatcher, returnKey};
- println "# Now cutting to clipboard.";
- UseKeyboardEquivalent("a");
- UseKeyboardEquivalent("x");
-
- for each singleString in gTheListOfStrings
- begin
- println "# Now typing: {singleString}";
- type k:{singleString, returnKey};
- UseKeyboardEquivalent("t");
- end;
-
- for counter := 1 to 5
- begin
- println "# Now pasting from clipboard.";
- UseKeyboardEquivalent("v");
- end;
- end;
-
- (************************************************************************************
- * Task EditTheText()
- * This task will perform a search and replace on the the text in the
- * currently active window. Note that errors in typing may cause this task
- * to fail.
- ************************************************************************************)
- task EditTheText(stringToSearch := "", stringToReplace := "")
- begin
-
- global gEditMenuName;
- global gFindDialogName;
- global gFindButtonName;
- global gChangeButtonName;
-
- println "# Now performing Find/Change operations.";
-
- match [window o:1 r:?docPosition];
- select [menuItem t:/{gFindDialogName}≈/ m:gEditMenuName];
- drag [window o:1 t:gFindDialogName] a:{docPosition[1],docPosition[2]};
- type k:{stringToSearch, tabKey, stringToReplace};
- select [button t:gFindButtonName w:gFindDialogName];
- match [window o:1 s:?topWinStyle];
- if (topWinStyle = dialog)
- begin
- select [button t:/≈OK≈/ w:[window o:1]];
- println "### Find command failed!";
- end;
- else
- select [button t:gChangeButtonName w:gFindDialogName];
- close [window t:gFindDialogName];
- end;
-
- # Main Script
- script MWLocalMain()
- begin
- localVersion := getLocalVersion();
-
- usaMenuID := 128;
- usaDialogID := 130;
- usaMenuItemID := 132;
- usaMessageID := 134;
- espMenuID := 129;
- espDialogID := 131;
- espMenuItemID := 133;
- espMessageID := 135;
-
- if (localVersion = "USA")
- begin
- menuID := usaMenuID;
- dialogID := usaDialogID;
- menuItemID := usaMenuItemID;
- messageID := usaMessageID;
- end;
- else if (localVersion = "Spanish")
- begin
- menuID := espMenuID;
- dialogID := espDialogID;
- menuItemID := espMenuItemID;
- messageID := espMessageID;
- end;
-
- global gFileMenuName := getIndString(menuID, 1);
- global gEditMenuName := getIndString(menuID, 2);
- global gFontMenuName := getIndString(menuID, 3);
- global gSizeMenuName := getIndString(menuID, 4);
- global gStyleMenuName := getIndString(menuID, 5);
- global gFormatMenuName := getIndString(menuID, 6);
- global gFindDialogName := getIndString(dialogID, 1);
- global gFindButtonName := getIndString(dialogID, 2);
- global gChangeButtonName := getIndString(dialogID, 3);
- global gSaveButtonName := getIndString(dialogID, 4);
- global gYesButtonName := getIndString(dialogID, 5);
- global gReplaceButtonName := getIndString(dialogID, 6);
- global gNewMenuItemName := getIndString(menuItemID, 1);
- global gOpenMenuItemName := getIndString(menuItemID, 2);
- global gSaveAsMenuItemName := getIndString(menuItemID, 3);
- global gCharacterMenuItemName := getIndString(menuItemID, 4);
- global gTheCatcher := getIndString(messageID,1);
- global gTheListOfStrings := {" ", " ", " "};
- gTheListOfStrings := replace(getIndString(messageID,2),1,gTheListOfStrings);
- gTheListOfStrings := replace(getIndString(messageID,3),2,gTheListOfStrings);
- gTheListOfStrings := replace(getIndString(messageID,4),3,gTheListOfStrings);
-
- theSearchString := gTheListOfStrings[2];
- theReplaceString := "this application, which we think is the best in Automated Testing.";
- savedName := "VU MacWriteII Demo";
-
- println "# Beginning MacWrite II Tests";
-
- # Create the new document.
- select [menuItem t:gNewMenuItemName m:gFileMenuName];
- GenerateSomeText();
-
- # Save and close it.
- DoSaveAsLocal(savedName);
- close [window t:savedName];
-
- # Reopen the document and edit it.
- select [menuItem t:/{gOpenMenuItemName}≈/ m:gFileMenuName];
- SelectFromStandardFile({ConcatStrings({savedName[1],savedName[2],savedName[3]})},
- 0);
- EditTheText(theSearchString, theReplaceString);
-
- # Save it again.
- DoSaveAsLocal(savedName);
-
- close [window t:savedName o:1];
- end;